﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using System.IO;

namespace Arcanum.Game.Client.Presentation.Views
{
    public class TextBoxStreamWriter : TextWriter
    {
        private TextBox output = null;

        public TextBoxStreamWriter(TextBox output)
        {
            this.output = output;
        }

        public override void Write(char value)
        {
            base.Write(value);
            output.Dispatcher.BeginInvoke(new Action(() =>
            {
                output.AppendText(value.ToString());
            }));// When character data is written, append it to the text box. 
        }

        public override Encoding Encoding
        {
            get { return System.Text.Encoding.UTF8; }
        }
    }
}
